import { ADD_CONTER, ADD_CART } from './mutations-type'

export default  {
    addToCart(context, payload) {
    let oldProduct = null;
    for(let item of context.state.cartList) {
      if(item.iid === payload.iid) {
        oldProduct = item
      }

    }
    if(oldProduct) {
      // oldProduct.count += 1
      context.commit(ADD_CONTER,oldProduct)
      resolve('商品添加 1+')
    }else {
      payload.count = 1
      // context.state.cartList.push(payload)
      context.commit(ADD_CART,oldProduct)
      resolve('添加新商品')
    }
}


}
